function beginContact(a, b, coll)
    local catA = a:getCategory()    
    local catB = b:getCategory()
    
    --Player
    if (catA == 2 and catB ~= 3) or (catB == 2 and catA ~= 3) then
      --Determine which object is which and store it locally
      local play = {}
      local object = {}
      if catA == 2 then
        play = {cat = catA, fix = a, e = a:getUserData()}
        object = {cat = catB, fix = b, e = b:getUserData()}
      else
        object = {cat = catA, fix = a, e = a:getUserData()}
        play = {cat = catB, fix = b, e = b:getUserData()}
      end
      
      --Apply damage if possible
      if object.e.damage then
        play.e.health.value = play.e.health.value - object.e.damage.amount
      end
      
      --Kill player instantly if they hit an asteroid
      if object.cat == 1 then
        play.e.health.value = 0
      end
    end
    
  
    --Player lasers
    if (catA == 3) and (catB ~= 2) then
      local e = a:getUserData()
      EntitySystem.delete(e)
            
      --Earn points for hitting something other than an asteroid or laser
      if catB ~= 1 and catB ~= 5 and catB ~= 8 and catB ~= 9 then
        gameScore = gameScore + 10
      end
    elseif (catA ~= 2) and (catB == 3) then
      local e = b:getUserData()
      EntitySystem.delete(e)
       --Earn points for hitting something other than an asteroid or laser
      if catA ~= 1 and catA ~= 5  and catA ~= 8 and catA ~= 9 then
        gameScore = gameScore + 10
      end
    end
    
   
   --Player EMP
   if (catA == 9 and catB ~= 2 and catB ~=5) or (catB == 9 and catA ~= 2 and catA ~= 5) then
      local em = {}
      local ob = {}
      if catA == 9 then
        em = {fix = a, e = a:getUserData(), cat = catA}
        ob = {fix = b, e = b:getUserData(), cat = catB}
      else
        ob = {fix = a, e = a:getUserData(), cat = catA}
        em = {fix = b, e = b:getUserData(), cat = catB}
      end
      
      if em.e.audio then
        love.audio.stop(em.e.audio.source)
      end
      
      --Earn points for hitting something othethan an asteroid or laser
      if ob.e.cat ~= 1 and ob.e.cat ~= 5 and ob.e.cat ~= 8 and ob.e.cat ~= 9 then
          gameScore = gameScore + 5
      end
      
      EntitySystem.delete(em.e)
      if ob.e then
        EntitySystem.attach(ob.e, 'disableTP')
        EntitySystem.detach(ob.e, 'trackPlayer')
        if ob.e.reload then
          ob.e.reload.isFiring = false
        end
        
      end
    end
   --
   --
   --Enemy Lasers
    if catA == 5 and catB ~= 4 then
      local e = a:getUserData()
      EntitySystem.delete(e)
    elseif catB == 5 and catA ~= 4 then
      local e = b:getUserData()
      EntitySystem.delete(e)
    end
    
    
    
    --Did an enemy run into something?
    --Basic Enemy
    if catA == 4 or catB == 4 then
      local en = {}
      local ob = {}
      if catA == 4 then
        en = {fix = a, e = a:getUserData(), cat = catA}
        ob = {fix = b, e = b:getUserData(), cat = catB}
      else
        ob = {fix = a, e = a:getUserData(), cat = catA}
        en = {fix = b, e = b:getUserData(), cat = catB}
      end
      
      if en.e.position and ob.cat ~= 5 and ob.cat ~= 9 then
        en.e.onDeath.needsRun = true
      end  
    end
    
    --
    --Speeder
    if (catA == 6 and catB ~= 9) or (catB == 6 and catA ~= 9) then
      local en = {}
      local ob = {}
      if catA == 6 then
        en = {fix = a, e = a:getUserData(), cat = catA}
        ob = {fix = b, e = b:getUserData(), cat = catB}
      else
        ob = {fix = a, e = a:getUserData(), cat = catA}
        en = {fix = b, e = b:getUserData(), cat = catB}
      end
      
      if en.e.position then
        en.e.onDeath.needsRun = true
      end  
    end
    
    --
    --Mines
    if (catA == 7 and catB ~= 9) or (catB == 7 and catA ~= 9) then
      local en = {}
      local ob = {}
      if catA == 7 then
        en = {fix = a, e = a:getUserData(), cat = catA}
      else
        en = {fix = b, e = b:getUserData(), cat = catB}
      end
      if en.e.position then
        en.e.onDeath.needsRun = true
      end  
    end
  
end